package br.com.cast.scc.service;

import java.util.Iterator;
import java.util.List;

import javax.transaction.Transactional;

import org.apache.wicket.model.IModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import br.com.cast.scc.dao.VeiculoDAO;
import br.com.cast.scc.enums.StatusRegistroAtivo;
import br.com.cast.scc.model.Veiculo;

@Component
public class VeiculoServiceImpl implements VeiculoService {

	@Autowired
	private VeiculoDAO veiculoDAO;
	
	/**
	 * @author Thiago
	 */
	private static final long serialVersionUID = 1L;

	@Transactional
	@Override
	public void salvar(Veiculo veiculo) {
		if( veiculo.getCodigo() == null){
			veiculo.setStatus(StatusRegistroAtivo.ATIVO.getSituacao());
			veiculoDAO.salvar(veiculo);
		}
		else{
			veiculoDAO.alterar(veiculo);
		}
	}
	
	
}
